Skip to content

[google_maps_flutter] Add onPointOfInterestTap callback#11872

Open
tenninebt wants to merge 1 commit into
flutter:mainfrom
tenninebt:google-maps-on-poi-tap
Open

[google_maps_flutter] Add onPointOfInterestTap callback#11872
tenninebt wants to merge 1 commit into
flutter:mainfrom
tenninebt:google-maps-on-poi-tap

Conversation

@tenninebt

@tenninebt tenninebt commented Jun 8, 2026

Copy link
Copy Markdown

Adds GoogleMap.onPointOfInterestTap, a callback that fires when the user taps a built-in map point of interest. The callback receives a PointOfInterestId containing the place ID only, matching maintainer feedback on #4052 and #10963.

The change is wired through the federated plugin stack: platform_interface (type + event stream), Android (OnPoiClickListener), iOS including sdk9/sdk10/shared (didTapPOIWithPlaceID), web (IconMouseEvent.placeId on map click), and the app-facing google_maps_flutter package. Tests cover Dart unit tests, Android Robolectric, iOS native, and web integration tests in the web example.

Fixes flutter/flutter#60695

Pre-Review Checklist

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2

Expose a place-ID-only POI tap stream across the federated plugin stack
(Android, iOS, web) so apps can react when users tap built-in map POIs.

Fixes flutter/flutter#60695
@tenninebt tenninebt force-pushed the google-maps-on-poi-tap branch from 336fb13 to e125948 Compare June 13, 2026 07:30
@tenninebt tenninebt marked this pull request as ready for review June 13, 2026 07:31

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for tapping points of interest (POIs) on the map across Android, iOS, and Web platforms in the google_maps_flutter plugin. It introduces the PointOfInterestId type and PointOfInterestTapEvent in the platform interface, exposes the onPointOfInterestTap callback on the GoogleMap widget, and implements the platform-specific event handling and Pigeon messaging. The review feedback suggests adding a defensive null check for the PointOfInterest parameter in the Android onPoiClick handler to prevent a potential NullPointerException.

Comment on lines +390 to +395
public void onPoiClick(PointOfInterest pointOfInterest) {
if (pointOfInterest.placeId != null) {
flutterApi.onPointOfInterestTap(
pointOfInterest.placeId, (Result<Unit> result) -> Unit.INSTANCE);
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Defensively checking pointOfInterest for null before accessing its properties is a good practice to prevent potential NullPointerExceptions, especially since the parameter is not annotated with @NonNull.

Suggested change
public void onPoiClick(PointOfInterest pointOfInterest) {
if (pointOfInterest.placeId != null) {
flutterApi.onPointOfInterestTap(
pointOfInterest.placeId, (Result<Unit> result) -> Unit.INSTANCE);
}
}
public void onPoiClick(PointOfInterest pointOfInterest) {
if (pointOfInterest != null && pointOfInterest.placeId != null) {
flutterApi.onPointOfInterestTap(
pointOfInterest.placeId, (Result<Unit> result) -> Unit.INSTANCE);
}
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The placeId null guard is the important part, and it’s already there. The Maps SDK only calls onPoiClick with a non-null PointOfInterest when a POI is tapped, and the other click handlers in this class don’t null-check their parameters either. We already have a test for the realistic case (placeId == null), which matches iOS. An extra pointOfInterest != null check would be harmless but unnecessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[google_maps_flutter] Add callback for click on google poi's on the map

1 participant